package net.borderwars.map;

/**
 * User: Eric
 * Date: Nov 21, 2004
 * Time: 8:43:28 PM
 */
public class Location {
    private int x;
    private int y;

    private long time;
    public static final int UNKNOWN = -100;

    public Location (int x, int y) {
        this (x, y, UNKNOWN);
    }

    public Location (int x, int y, long time) {
        this.x = x;
        this.y = y;
        this.time = time;
    }

    public int distance (Location two) {
        return (int) Math.sqrt (Math.pow (two.x - x, 2) + Math.pow (two.y - y, 2));
    }

    public int getX () {
        return (x);
    }

    public int getY () {
        return (y);
    }

    public Location project (long time, Velocity v) {
        Location rtn = new Location ((int) (x + (time * v.getVX ())), (int) (y + (time * v.getVY ())));
        return (rtn);
    }

    public long timeToReach (Location dest, Velocity v) {
        return (v.timeBetween (this, dest));
    }

    public double angle (Location l) {
        int dx = (int) (l.getX () - x);
        int dy = (int) (l.getY () - y);
        return (Math.atan ((double) dy / (double) dx));
    }

    public String toString () {
        return "Location{" + "x=" + x + ", y=" + y + "}";
    }
}
